FROM ubuntu:22.04
RUN apt update  && apt upgrade -y && apt install -y build-essential libpcre3-dev zlib1g-dev libssl-dev && groupadd -g 2021 haproxy && useradd -g haproxy -s /bin/false -u 2021 haproxy

ADD haproxy-3.0.2.tar.gz /usr/local/src

RUN cd /usr/local/src/haproxy-3.0.2 && make ARCH=amd TARGET=linux-glibc USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 PREFIX=/usr/local/haproxy && make install PREFIX=/usr/local/haproxy && cp /usr/local/haproxy/sbin/haproxy /usr/sbin && mkdir /run/haproxy/ /var/lib/haproxy
ADD haproxy.cfg /etc/haproxy/haproxy.cfg

EXPOSE 9999

CMD [ "haproxy","-f","/etc/haproxy/haproxy.cfg" ]